﻿using Sunny.UI;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace OtherDevice
{
    public partial class Form_DP螺丝机 : Form_ControlBase
    {
        public Form_DP螺丝机()
        {
            InitializeComponent();
        }
        Screw_DP dp;
        public override void FlushToDlg(object devicebase)
        {
            try
            {
                if (devicebase == null)
                    return;
                this.dp = devicebase as Screw_DP;
                this.Dock = DockStyle.Fill;
                this.Show();
            }
            catch (Exception)
            {

            }

        }
        private void btn_获取扭力_Click(object sender, EventArgs e)
        {
            timer1.Interval = 50;
            timer1.Start();
        }

        private void btn_停止_Click(object sender, EventArgs e)
        {
            lbl_测量值.Text = $"扭力：---    角度：---";
            timer1.Stop();
        }

        private void timer1_Tick(object sender, EventArgs e)
        {
            try
            {
                dp.Function_GetScrewTorque(out double torque);
                dp.Function_GetScrewAngle(out double angle);
                lbl_测量值.Text = $"扭力：{torque.ToString("0.000")}    角度：{angle.ToString("0.000")}";
            }
            catch (Exception)
            {

            }
        }
    }
}
